<script type="text/javascript">

    $(document).ready(function() {


        //$("#id").autoNumeric({aSep: '.', aDec: ','});


        $("#btn_pilih_rekening").click(function() {
            //alert('aaa');
            $("#dialog-rekening").dialog('open');
        });

        $("#btn_cari_PemilikWP").click(function() {
            $("#dialog-pemilikWp").dialog('open');
        });

    });

    $("#nomor_induk").keyup(function(e){
        if (e.keyCode == '114'){
            $("#dialog-pemilikWp").dialog("open");
        }		
    });


    function PilihRekening(aa) {
        var cc = aa.split("#");
        $("#no_rekening").val(cc[0]);        
        $("#nama_rekening").val(cc[1]);

        $("#dialog-rekening").dialog('close');
    }


    function PilihDataPemilikWp(aa) {
        var cc = aa.split("#");
	
        //function untuk memecah string
        //        $("#npwpd").val(cc[0]);
        //        var npwpd1=cc[0].substr(0,1); //dimulai dari string ke 0 di ambil 1 string
        //        var npwpd2=cc[0].substr(1,1);
        //        var npwpd3=cc[0].substr(2,7); //dimulai dari string ke 2 di ambil 7 string
        //        var npwpd4=cc[0].substr(9,2); //dimulai dari string ke 9 di ambil 2 string
        //        var npwpd5=cc[0].substr(11,3); //dimulai dari string ke 11 di ambil 3 string
        //		 
        //        $("#npwpd1").val(npwpd1);
        //        $("#npwpd2").val(npwpd2);
        //        $("#npwpd3").val(npwpd3);
        //        $("#npwpd4").val(npwpd4);
        //        $("#npwpd5").val(npwpd5);

		
        $("#nomor_induk").val(cc[0]);        
        $("#nama_pemilik").val(cc[1]);
        $("#alamat_pemilik").val(cc[2]);
        $("#kecamatan").val(cc[3]);
        $("#kelurahan").val(cc[4]);
        $("#rt").val(cc[5]);
        $("#rw").val(cc[6]);
        $("#kode_pos").val(cc[7]);
        $("#kabupaten").val(cc[8]);
        $("#warga_negara").val(cc[9]);
		
        $("#dialog-pemilikWp").dialog('close');
    }




</script>

<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'horizontalForm',
    'type' => 'horizontal',
    'enableAjaxValidation' => false,
//    'action'=>Yii::app()->createUrl('');
        ));
?>

<legend>Retribusi Badan Usaha</legend>
<br>
<?php echo $form->errorSummary($model); ?>
<div class="row-fluid">
    <div class="span6">
        <div class="control-group ">
            <label class="control-label" >No Urut </label>
            <div class="controls">
                <?php
                $query = "SELECT MAX(no_formulir) AS NoFormulir2 FROM data_npwpd";
                $hasil = Yii::app()->db->createCommand($query)->queryRow();
                if ($hasil['noformulir2'] == 0) {
                    $input = 1;
                    $nomor = str_pad($input, 7, "0", STR_PAD_LEFT);  // produces "-=-=-Alien"
                } else {
                    $input = $hasil['noformulir2'] + 1;
                    $nomor = str_pad($input, 7, "0", STR_PAD_LEFT);  // produces "-=-=-Alien"
                }
                $valRef = 'WP' . date('Y') . $nomor;
//            if ($NoUrut < 10) {
//                $valRef = 'WP' . date('Y') . $NoUrut;
//            } else if ($NoUrut < 100) {
//                $valRef = 'WP' . date('Y') . $NoUrut;
//            } else if ($NoUrut < 1000) {
//                $valRef = 'WP' . date('Y') . $NoUrut;
//            } else {
//                $valRef = 'WP' . date('Y') . $NoUrut;
//            }
                echo $form->textField($modelDataNpwpd, 'no_formulir', array('class' => 'span6', 'readonly' => true, 'value' => $valRef, 'maxlength' => 20));
                ?>
            </div>
        </div>
    </div>
    <div class="span6">
        <div class="control-group ">
            <label class="control-label"> No Formulir</label>
            <div class="controls">
                <?php
                $query = "SELECT MAX(no_formulir) AS NoFormulir2 FROM data_npwpd";
                $hasil = Yii::app()->db->createCommand($query)->queryRow();
                if ($hasil['noformulir2'] == 0) {
                    $input = 1;
                    $nomor = str_pad($input, 8, "0", STR_PAD_LEFT);  // produces "-=-=-Alien"
                } else {
                    $input = $hasil['noformulir2'] + 1;
                    $nomor = str_pad($input, 8, "0", STR_PAD_LEFT);  // produces "-=-=-Alien"
                }
                ?>
                <?php echo $form->textField($modelDataNpwpd, 'no_formulir', array('id' => 'no_formulir', 'class' => 'span6', 'value' => $nomor, 'readOnly' => true)); ?>
<!--            <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
<input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">-->
            </div>
        </div>
    </div>
</div>

<div class="alert alert-info">A. Badan Usaha </div>
<div class="row-fluid">
    <div class="control-group ">
        <label class="control-label" >Nama Badan Usaha </label>
        <div class="controls">
            <?php echo $form->textField($modelWpBadanUsaha, 'nama_badan', array('id' => 'nomor_induk', 'class' => 'span4', 'maxlength' => 125)); ?>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="control-group ">
        <label class="control-label" >Alamat </label>
        <div class="controls">
            <?php echo $form->textField($modelWpBadanUsaha, 'alamat_badan', array('id' => 'nomor_induk', 'class' => 'span4', 'maxlength' => 125)); ?>
        </div>            
    </div>
</div>
<div class="row-fluid">
    <div class="span6">
        <div class="row-fluid">
            <div class="span6">
                <div class="control-group">
                    <label class="control-label">RT</label>
                    <div class="controls">
                        <!--input type="text" class="span1" style="width:20px; " readonly id="rt"-->
                        <?php echo $form->textField($modelWpBadanUsaha, 'rt_badan', array('id' => 'rt', 'class' => 'span8')); ?>
                    </div>
                </div>
            </div>
            <div class="span6">
                <div class="control-group">
                    <label class="control-label" style="margin-left: -30px;">RW</label>
                    <div class="controls">
                          <?php echo $form->textField($modelWpBadanUsaha, 'rw_badan', 
                                  array('id' => 'rw','style'=>'margin-left:-120px;', 'class' => 'span8')); ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="span6">
        <div class="control-group ">
            <label class="control-label" >Kecamatan </label>
            <div class="controls">
                <?php echo $form->textField($modelWpBadanUsaha, 'kecamatan_badan', array('id' => 'nomor_induk', 'class' => 'span8', 'maxlength' => 125)); ?>
                <?php
                $this->widget('bootstrap.widgets.TbButton', array(
                    'id' => 'btn_pilih_Pejabat',
                    'type' => 'primary',
                    'label' => 'F1',
                ));
                ?>
            </div>
        </div>
    </div>
    <div class="span6">
        <div class="control-group" style="margin-left:-70px;">
            <label class="control-label" style="margin-right:-50px;" >Kelurahan</label> 
            <div class="controls">
                <?php echo $form->textField($modelWpBadanUsaha, 'kelurahan_badan', array('id' => 'nomor_induk', 'class' => 'span8', 'maxlength' => 125)); ?>
            </div>
        </div>
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Kabupaten </label>
    <div class="controls">

        <?php echo $form->textField($modelWpBadanUsaha, 'kabupaten_badan', array('id' => 'nomor_induk', 'class' => 'span2', 'maxlength' => 125)); ?>

        <label class="control-label">Kode Pos </label>

        <?php echo $form->textField($modelWpBadanUsaha, 'kode_posbu', array('id' => 'nomor_induk', 'class' => 'span2', 'maxlength' => 125)); ?>
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Telepon </label>
    <div class="controls">
        <?php echo $form->textField($modelWpBadanUsaha, 'no_telepon_badan', array('id' => 'nomor_induk', 'class' => 'span2', 'maxlength' => 125)); ?>
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Bidang Usaha</label>
    <div class="controls">
        <?php
        echo $form->DropDownList($modelWpBadanUsaha, 'bidang_usaha', array(
            'prompt' => 'Pilih',
            '0' => '00.Lain-Lain',
            '1' => '01.Hotel',
            '2' => '02.Restoran',
            '3' => '03.Hiburan',
            '4' => '04.Reklame',
            '5' => '05.Galian Golongan C',
            '6' => '06.Air Tanah',
                ), array('class' => 'span3'));
        ?>
    </div>
</div>


<label class="control-label" >Surat Izin Yang Dimiliki</label>


<table class="table table-bordered table-striped" style="margin-left:20px;width: 420px;  ">
    <thead>
        <tr><th>Nomor Surat</th><th>Surat Izin</th><th>Tanggal</th></tr>
    </thead>
    <tbody>
        <tr><td></td><td></td><td></td></tr>
        <tr><td></td><td></td><td></td></tr>


    </tbody>

</table>
<div class="tambah" style="margin-left:160px;margin-top:-15px;">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'id' => 'btn_pilih_Pejabat',
        'type' => 'primary',
        'label' => 'add',
    ));
    ?>            
</div>
<br>

<div class="alert alert-info">B. Pemilik/Pengelola </div>

<div class="control-group ">
    <label class="control-label" for="TestForm_textField">Nomor Bukti Diri </label>
    <div class="controls">
<!--                <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        -
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        -
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        -
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        -
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        -
        <input type = "text" name="no_op_input[]"  class="span1" id="nop1" style="width:20px;">
        -->
        <?php echo $form->textField($model, 'nomor_induk', array('id' => 'nomor_induk', 'class' => 'span3', 'maxlength' => 125)); ?>
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'type' => 'info',
            'label' => 'Check Nomor (F1)',
            'htmlOptions' => array('id' => 'btn_check_nomor1')
        ));
        ?>
    </div>
</div>
<div class="control-group ">
    <label class="control-label" ></label>
    <div class="controls">
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'type' => 'info',
            'label' => 'Cari Data (F9)',
            'htmlOptions' => array('id' => 'btn_cari_PemilikWP')
        ));
        ?>
    </div>
</div>


<div class="control-group ">
    <label class="control-label" >Nama Lengkap </label>
    <div class="controls">
        <input type="text" class="span3" readonly id="nama_pemilik" >

        <label class="control-label" style="width:120px; ">Alamat Wajib Pajak </label>
        <input type="text" class="span4" readonly id="alamat_pemilik">
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Kecamatan </label>
    <div class="controls">
        <input type="text" class="span3" readonly id="kecamatan">

        <label class="control-label" style="width:120px; ">Kelurahan/Desa </label>
        <input type="text" class="span4" readonly id="kelurahan">
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >RT </label>
    <div class="controls">
        <input type="text" class="span1" style="width:20px; " readonly id="rt">

        RW 
        <input type="text" class="span1" style="width:20px;" readonly id="rw">
        <label class="control-label">Kode Pos </label>
        <input type="text" class="span2"  readonly id="kode_pos">
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Kabupaten </label>
    <div class="controls">
        <input type="text" class="span3" readonly id="kabupaten">

        <label class="control-label" style="width: 100px;">Kewarganegaraan </label>
        <input type="text" class="span2" readonly id="warga_negara">
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Telepon </label>
    <div class="controls">
        <?php echo $form->textField($modelWpBadanUsaha, 'no_telepon_pemilik', array('id' => 'no_telepon_pemilik', 'class' => 'span3', 'maxlength' => 125)); ?>
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Jabatan </label>
    <div class="controls">
        <?php echo $form->textField($modelWpBadanUsaha, 'jabatan', array('id' => 'jabatan', 'class' => 'span3', 'maxlength' => 125)); ?>
    </div>
</div>

<div class="alert alert-info"> C. Pencatatan</div>

<div class="control-group ">
    <label class="control-label">NPWPD</label>
    <div class="controls">
        <?php
        echo $form->DropDownList($modelDataNpwpd, 'npwpd', array(
            'prompt' => 'Pilih',
            '0' => 'P',
            '1' => 'I',
            '2' => 'R',
                ), array('class' => 'span1'));
        ?>
        <input type="text" class="span1" style="width: 20px;" >
        -
        <input type="text" class="span2" value="000005" >
        -
        <input type="text" class="span1" style="width: 20px;" value="01" >
        -
        <input type="text" class="span1" style="width: 40px;" >
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >Petugas </label>
    <div class="controls">
        <input type="text" class="span2" value="Dany Erlangga" >
    </div>
</div>

<div class="control-group ">
    <label class="control-label" >NIP </label>
    <div class="controls">
        <input type="text" class="span3" value="123070123" >
    </div>
</div>

<div class="alert alert-info">D. Pendataan</div>

<div class="control-group ">
    <label class="control-label" >Petugas </label>
    <div class="controls">
        <input type="text" class="span2" value="Dany Erlangga" >
    </div>
</div>
<div class="control-group ">
    <label class="control-label" >NIP </label>
    <div class="controls">
        <input type="text" class="span3" value="123070123" >
    </div>
</div>


<div class="control-group ">
    <label class="control-label" >Tanggal Pendataan </label>
    <div class="controls">
        <input type="text" class="span2"  >
    </div>
</div>


<label class="control-label" >Kewajiban Pajak </label>
<div class="control-group ">
    <div class="controls">
        <?php
        echo $form->checkBoxList($modelDataNpwpd, 'cara_hitung', array(
            'Pajak Hotel',
            'Pajak Restoran',
            'Pajak Hiburan',
            'Pajak Reklame',
            'Pajak Penerangan Jalan',
            'Galian GOL C',
            'Air Tanah',
            'Pajak Parkir',
        ));
        ?>

    </div>
</div>



<div class="form-actions">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'buttonType' => 'submit',
        'type' => 'primary',
        'label' => $model->isNewRecord ? 'Simpan' : 'Save',
    ));
    ?>
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'buttonType' => 'reset',
        'type' => 'primary',
        'label' => $model->isNewRecord ? 'Batal' : 'Reset',
    ));
    ?>

</div>


<?php $this->endWidget(); ?>

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id' => 'dialog-pemilikWp',
    'options' => array(
        'title' => 'Cari Data NPWPD',
        'overflow' => 'scroll',
        'width' => 900,
        'height' => 500,
        'autoOpen' => false,
    ),
));
?>

<?php
Yii::app()->clientScript->registerScript('datanpwpd', "
			$('form#wajibpajak').submit(function(){
				$.fn.yiiGridView.update('DataNpwpd', {
					data: $(this).serialize()
				});
				return false;
			});
		
		");
?>

<form method="get" class="form-horizontal" action="<?php echo Yii::app()->createUrl($this->route); ?>" id="datanpwpd">
    <div class="alert alert-info">
        <div class="control-group">
            <label class="control-label">NPWPD </label>
            <div class="controls">
                <input type="text" class="span3" name="DataNpwpd[npwpd]" id="datanpwpd_npwpd" /> 
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Nama Wajib Pajak </label>
            <div class="controls">    
                <input type="text" class="span3" name="DataNpwpd[nama_npwpd]" id="DataNpwpd_nama_npwpd" />
                <!--button class="btn btn-primary" id="btn_search" type="submit" name="btn_search">Cari</button-->
            </div>
        </div>

        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'buttonType' => 'submit',
            'icon' => 'search',
            'htmlOptions' => array(
                'id' => 'btn_search',
                'style' => 'margin-left:20px;',
            ),
            'label' => 'Cari',
        ));
        ?>
    </div>
</form>


<?php
$this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'DataNpwpd',
    'dataProvider' => $modelPemilikWp->search(),
    'type' => 'striped bordered condensed',
    'columns' => array(
        array(
            'header' => 'Nomor Bukti',
            'value' => '$data->nomor_induk',
        ),
        array(
            'header' => 'Nama Lengkap',
            'value' => '$data->nama_pemilik',
        ),
        array(
            'header' => 'Alamat',
            'value' => '$data->alamat_pemilik',
        ),
        array(
            'header' => 'Kelurahan',
            'value' => '$data->kelurahan',
        ),
        array(
            'header' => 'Kecamatan',
            'value' => '$data->kecamatan',
        ),
        array(
            'header' => 'Kabupaten',
            'value' => '$data->kabupaten',
        ),
        array(
            'value' => 'CHtml::Button("Pilih",
                array("onClick" => "PilihDataPemilikWp(\'".$data->nomor_induk."#".
                $data->nama_pemilik."#".
                $data->alamat_pemilik."#".
                $data->kelurahan."#".
                $data->kecamatan."#".
                $data->rt."#".
                $data->rw."#".
                $data->kode_pos."#".
                $data->kabupaten."#".
		$data->warga_negara."\'
                )",
				"class"=>"btn btn-info",
				))',
            'type' => 'raw',
            'htmlOptions' => array(
                'style' => 'text-align:center',
            ),
        ),
    ),
));
?>


<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
<!-- End dialog data NWPD -->